Plan for Analysis

Other notes Also leave one speaker out and try classification. If the reslt is good we can use it to predict tone produced on what kind of level (leave the noise level aside). The noise shouldn’t matter much at this stage. (18 levels?) look at similarity of tones (using clustering).

# Read in all the F0 contour info. All of these f0.mat files have been downsampled
# in MatLab during linear interpolation (see getf0.mat in the matlab codes)

# matlab code:
# myFolder = '\\client\h$\Desktop\ProsodyPro\m-3-78\channel1';
# myFiles = dir(fullfile(myFolder,'*.wav')); %gets all wav files
# 
# for k = 1:length(myFiles)
#   baseFileName = myFiles(k).name;
#   fullFileName = fullfile(myFolder, baseFileName);
#   fprintf(1, 'Now reading %s\n', fullFileName);
#   [y, Fs] = audioread(fullFileName);
#   [f0, ~] = pitchRocco(y, Fs);
#   i = 1:length(f0);
#   i_new =  linspace(min(i), max(i), 20);
#   f0_downsampled = interp1(i, f0, i_new, 'linear');  
#   fid= fopen(fullfile(myFolder, 'F0.mat'),'a');
#   fprintf(fid, '%s ', baseFileName);
#   fprintf(fid, '%f ', f0_downsampled);
#   fprintf(fid,'\n');
#   fclose(fid);
# end

# Step 1: Read in all F0.mat files into f0Files and assign a name for each

f0Files <- lapply(Sys.glob("*/channel1/F0.mat"), read.table)
length(f0Files)
## [1] 15
f0_f_1_78 <- as.data.frame(f0Files[1])
f0_f_1_90 <- as.data.frame(f0Files[2])
f0_f_1_q <- as.data.frame(f0Files[3])
f0_f_2_78 <- as.data.frame(f0Files[4])
f0_f_2_90 <- as.data.frame(f0Files[5])
f0_f_2_q <- as.data.frame(f0Files[6])
f0_m_1_78 <- as.data.frame(f0Files[7])
f0_m_1_90 <- as.data.frame(f0Files[8])
f0_m_1_q <- as.data.frame(f0Files[9])
f0_m_2_78 <- as.data.frame(f0Files[10])
f0_m_2_90 <- as.data.frame(f0Files[11])
f0_m_2_q <- as.data.frame(f0Files[12])
f0_m_3_78 <- as.data.frame(f0Files[13])
f0_m_3_90 <- as.data.frame(f0Files[14])  
f0_m_3_q <- as.data.frame(f0Files[15]) 
# Step 2: Add column names for all dataframes.

numbers <- 1:22
cols <- c("sound.name",numbers)
colnames(f0_f_1_78) <- cols
colnames(f0_f_1_90) <- cols
colnames(f0_f_1_q) <- cols
colnames(f0_f_2_78) <- cols
colnames(f0_f_2_90) <- cols
colnames(f0_f_2_q) <- cols
colnames(f0_m_1_78) <- cols
colnames(f0_m_1_90) <- cols
colnames(f0_m_1_q) <- cols
colnames(f0_m_2_78) <- cols
colnames(f0_m_2_90) <- cols
colnames(f0_m_2_q) <- cols
colnames(f0_m_3_78) <- cols
colnames(f0_m_3_90) <- cols
colnames(f0_m_3_q) <- cols


# Assigning noise level
f0_f_1_78$noise = 78
f0_f_1_90$noise = 90
f0_f_1_q$noise = 0

f0_f_2_78$noise = 78
f0_f_2_90$noise = 90
f0_f_2_q$noise = 0

f0_m_1_78$noise = 78
f0_m_1_90$noise = 90
f0_m_1_q$noise = 0

f0_m_2_78$noise = 78
f0_m_2_90$noise = 90
f0_m_2_q$noise = 0

f0_m_3_78$noise = 78
f0_m_3_90$noise = 90
f0_m_3_q$noise = 0


# Assigning gender variable (0 for female and 1 for male)
f0_f_1_78$gender = 0
f0_f_1_90$gender = 0
f0_f_1_q$gender = 0

f0_f_2_78$gender = 0
f0_f_2_90$gender = 0
f0_f_2_q$gender = 0

f0_m_1_78$gender = 1
f0_m_1_90$gender = 1
f0_m_1_q$gender = 1

f0_m_2_78$gender = 1
f0_m_2_90$gender = 1
f0_m_2_q$gender = 1

f0_m_3_78$gender = 1
f0_m_3_90$gender = 1
f0_m_3_q$gender = 1


### Concatenate all dataframes
f0_reports <- rbind(f0_f_1_78, f0_f_1_90, f0_f_1_q,
                    f0_f_2_78, f0_f_2_90, f0_f_2_q,
f0_m_1_78, f0_m_1_90, f0_m_1_q,
f0_m_2_78, f0_m_2_90, f0_m_2_q,
f0_m_3_78, f0_m_3_90, f0_m_3_q)

dim(f0_reports)
## [1] 4732   25

According to the report, this dataframe has 4,732 records. In total, from 5 speakers, we have 4732 sound segments to analyze.

# Assign tone values.

# Extracting a substring that contains only the syllable names.
nameswithoutwav <- sapply(strsplit(f0_reports[,1], split=".", fixed=TRUE), "[", 1)
f0_reports$syllable.names <- sapply(strsplit(nameswithoutwav, split="_", fixed=TRUE), "[", 1)

f0_reports$tone <- ifelse(grepl("a", f0_reports$syllable.name, ignore.case=T), "A1",
ifelse(grepl("^tát", f0_reports$syllable.name, ignore.case=T), "D1",
ifelse(grepl("^tạt", f0_reports$syllable.name, ignore.case=T), "D2",
ifelse(grepl("^tết", f0_reports$syllable.name, ignore.case=T), "D1",
ifelse(grepl("^tệt", f0_reports$syllable.name, ignore.case=T), "D2",
ifelse(grepl("^tút", f0_reports$syllable.name, ignore.case=T), "D1",
ifelse(grepl("^tụt", f0_reports$syllable.name, ignore.case=T), "D2",
ifelse(grepl("à", f0_reports$syllable.name, ignore.case=T), "A2",
ifelse(grepl("á", f0_reports$syllable.name, ignore.case=T), "B1",
ifelse(grepl("ả", f0_reports$syllable.name, ignore.case=T), "C1",
ifelse(grepl("ã", f0_reports$syllable.name, ignore.case=T), "C2",
ifelse(grepl("ạ", f0_reports$syllable.name, ignore.case=T), "B2",
ifelse(grepl("ê", f0_reports$syllable.name, ignore.case=T), "A1",
ifelse(grepl("ề", f0_reports$syllable.name, ignore.case=T), "A2",
ifelse(grepl("ế", f0_reports$syllable.name, ignore.case=T), "B1",
ifelse(grepl("ể", f0_reports$syllable.name, ignore.case=T), "C1",
ifelse(grepl("ễ", f0_reports$syllable.name, ignore.case=T), "C2",
ifelse(grepl("ệ", f0_reports$syllable.name, ignore.case=T), "B2",
ifelse(grepl("u", f0_reports$syllable.name, ignore.case=T), "A1",
ifelse(grepl("ù", f0_reports$syllable.name, ignore.case=T), "A2",
ifelse(grepl("ú", f0_reports$syllable.name, ignore.case=T), "B1",
ifelse(grepl("ủ", f0_reports$syllable.name, ignore.case=T), "C1",
ifelse(grepl("ũ", f0_reports$syllable.name, ignore.case=T), "C2",
ifelse(grepl("ụ", f0_reports$syllable.name, ignore.case=T), "B2",
ifelse(grepl("ộ", f0_reports$syllable.name, ignore.case=T), "B2","NA")))))))))))))))))))))))))

# Assigning if the token is single (1) or not (0). Single tokens were produced in isolation.
# Otherwise they were produced in carrier sentences.
f0_reports$single <- ifelse(grepl("single", f0_reports$sound.name), 1, 0)

# Convert categorical variables to factor levels.
f0_reports$gender <- as.factor(f0_reports$gender)
f0_reports$single <- as.factor(f0_reports$single)
f0_reports$tone <- as.factor(f0_reports$tone)
f0_reports$noise <- as.factor(f0_reports$noise)

summary(f0_reports)
##   sound.name              1               2               3        
##  Length:4732        Min.   :  0.0   Min.   :  0.0   Min.   :  0.0  
##  Class :character   1st Qu.:  0.0   1st Qu.:120.8   1st Qu.:128.6  
##  Mode  :character   Median :125.7   Median :150.8   Median :155.8  
##                     Mean   :108.1   Mean   :148.2   Mean   :158.4  
##                     3rd Qu.:167.5   3rd Qu.:190.9   3rd Qu.:194.2  
##                     Max.   :376.5   Max.   :353.5   Max.   :369.9  
##                                                                    
##        4               5               6               7        
##  Min.   :  0.0   Min.   :  0.0   Min.   :  0.0   Min.   :  0.0  
##  1st Qu.:130.0   1st Qu.:129.5   1st Qu.:128.0   1st Qu.:125.6  
##  Median :157.5   Median :158.2   Median :157.7   Median :156.3  
##  Mean   :161.2   Mean   :161.1   Mean   :160.1   Mean   :157.7  
##  3rd Qu.:194.3   3rd Qu.:193.4   3rd Qu.:192.2   3rd Qu.:190.5  
##  Max.   :355.8   Max.   :320.7   Max.   :310.0   Max.   :304.2  
##                                                                 
##        8               9               10              11       
##  Min.   :  0.0   Min.   :  0.0   Min.   :  0.0   Min.   :  0.0  
##  1st Qu.:123.9   1st Qu.:121.8   1st Qu.:120.3   1st Qu.:119.1  
##  Median :154.9   Median :154.2   Median :153.8   Median :153.3  
##  Mean   :155.9   Mean   :154.4   Mean   :154.2   Mean   :153.1  
##  3rd Qu.:188.7   3rd Qu.:187.5   3rd Qu.:187.2   3rd Qu.:187.1  
##  Max.   :311.4   Max.   :346.5   Max.   :320.2   Max.   :307.4  
##                                                                 
##        12              13              14              15       
##  Min.   :  0.0   Min.   :  0.0   Min.   :  0.0   Min.   :  0.0  
##  1st Qu.:117.4   1st Qu.:116.1   1st Qu.:114.8   1st Qu.:113.2  
##  Median :152.4   Median :152.3   Median :152.0   Median :151.9  
##  Mean   :152.3   Mean   :150.9   Mean   :150.3   Mean   :150.2  
##  3rd Qu.:186.9   3rd Qu.:187.2   3rd Qu.:187.8   3rd Qu.:188.8  
##  Max.   :311.6   Max.   :318.9   Max.   :325.3   Max.   :332.6  
##                                                                 
##        16              17              18              19       
##  Min.   :  0.0   Min.   :  0.0   Min.   :  0.0   Min.   :  0.0  
##  1st Qu.:112.0   1st Qu.:110.1   1st Qu.:109.9   1st Qu.:108.2  
##  Median :151.5   Median :150.7   Median :151.1   Median :149.7  
##  Mean   :149.8   Mean   :149.7   Mean   :149.7   Mean   :147.4  
##  3rd Qu.:190.3   3rd Qu.:192.4   3rd Qu.:194.2   3rd Qu.:193.4  
##  Max.   :339.4   Max.   :393.9   Max.   :406.0   Max.   :428.0  
##                                                                 
##        20              21               22         noise     gender  
##  Min.   :  0.0   Min.   :  0.00   Min.   :  0.00   0 :1575   0:1893  
##  1st Qu.:103.8   1st Qu.: 95.53   1st Qu.:  0.00   78:1578   1:2839  
##  Median :144.3   Median :133.69   Median : 89.51   90:1579           
##  Mean   :142.3   Mean   :131.34   Mean   : 79.14                     
##  3rd Qu.:190.7   3rd Qu.:182.09   3rd Qu.:138.13                     
##  Max.   :413.7   Max.   :377.12   Max.   :343.06                     
##                                                                      
##  syllable.names          tone     single  
##  Length:4732        B2     :780   0:2366  
##  Class :character   A2     :719   1:2366  
##  Mode  :character   B1     :719           
##                     C1     :719           
##                     C2     :719           
##                     A1     :716           
##                     (Other):360

Aggregate Tone Analysis

F0 Plots

# # Confidence interval function using the t-distribution
# confidence_interval <- function(vector, interval) {
#   # Standard deviation of sample
#   vec_sd <- sd(vector)
#   # Sample size
#   n <- length(vector)
#   # Mean of sample
#   vec_mean <- mean(vector)
#   # Error according to t distribution
#   error <- qt((interval + 1)/2, df = n - 1) * vec_sd / sqrt(n)
#   # Confidence interval as a vector
#   result <- c("lower" = vec_mean - error, "upper" = vec_mean + error)
#   return(result)
# }

# Confidence interval function for a matrix using the t-distribution
confidence_interval_matrix <- function(matrix, interval) {
  # Standard deviation of sample
  vec_sd <- apply(matrix, 2, sd)
  # Sample size, assuming equal length of columns in the matrix
  n <- length(matrix[,1])
  # Mean of sample
  vec_mean <- colMeans(matrix)
  # Error according to the t-distribution
  error <- qt((interval + 1)/2, df = n - 1) * vec_sd / sqrt(n)
  # Confidence interval as a matrix of two columns
  result <- c("lower" = vec_mean - error, "upper" = vec_mean + error)
  return(result)
}

#confidence_interval(A1[,3],0.95) # this will return a lower and upper value of a vector.

# Note that I only plot the 3nd to 18th sampled points.
# Extract F0 of all tones A1 (574 instances)
par(mfrow=c(2,4))
A1 <- data.matrix(f0_reports[f0_reports$tone=="A1",-c(1,c(22:26))])
confidence_interval_matrix(A1[,3:18],0.95)[1:16]
##  lower.3  lower.4  lower.5  lower.6  lower.7  lower.8  lower.9 lower.10 
## 167.2276 168.7258 170.3379 170.1189 170.3816 170.5714 170.3337 169.7377 
## lower.11 lower.12 lower.13 lower.14 lower.15 lower.16 lower.17 lower.18 
## 168.6061 168.2545 167.3401 165.9767 165.1457 164.4174 164.1179 164.2718
plot(colMeans(A1)[3:18], type="l", xlim=c(1, 18), ylim=c(60, 200), xlab="Sampling points", ylab="F0 contour of tone A1")
lines(confidence_interval_matrix(A1[,3:18],0.95)[1:16], col="blue")
lines(confidence_interval_matrix(A1[,3:18],0.95)[17:32], col="blue")
# # Do the same for the other tones
A2 <- data.matrix(f0_reports[f0_reports$tone=="A2",-c(1,c(22:26))])
plot(colMeans(A2)[3:18], type="l", xlim=c(1, 18), ylim=c(60, 200), xlab="Sampling points", ylab="F0 contour of tone A2")
lines(confidence_interval_matrix(A2[,3:18],0.95)[1:16], col="blue")
lines(confidence_interval_matrix(A2[,3:18],0.95)[17:32], col="blue")

B1 <- data.matrix(f0_reports[f0_reports$tone=="B1",-c(1,c(22:26))])
plot(colMeans(B1)[3:18], type="l", xlim=c(1, 18), ylim=c(60, 200), xlab="Sampling points", ylab="F0 contour of tone B1")
lines(confidence_interval_matrix(B1[,3:18],0.95)[1:16], col="blue")
lines(confidence_interval_matrix(B1[,3:18],0.95)[17:32], col="blue")

B2 <- data.matrix(f0_reports[f0_reports$tone=="B2",-c(1,c(22:26))])
plot(colMeans(B2)[3:18], type="l", xlim=c(1, 18), ylim=c(60, 250), xlab="Sampling points", ylab="F0 contour of tone B2")
lines(confidence_interval_matrix(B2[,3:18],0.95)[1:16], col="blue")
lines(confidence_interval_matrix(B2[,3:18],0.95)[17:32], col="blue")

C1 <- data.matrix(f0_reports[f0_reports$tone=="C1",-c(1,c(22:26))])
plot(colMeans(C1)[3:18], type="l", xlim=c(1, 18), ylim=c(60, 250), xlab="Sampling points", ylab="F0 contour of tone C1")
lines(confidence_interval_matrix(C1[,3:18],0.95)[1:16], col="blue")
lines(confidence_interval_matrix(C1[,3:18],0.95)[17:32], col="blue")

C2 <- data.matrix(f0_reports[f0_reports$tone=="C2",-c(1,c(22:26))])
plot(colMeans(C2)[3:18], type="l", xlim=c(1, 18), ylim=c(60, 250), xlab="Sampling points", ylab="F0 contour of tone C2")
lines(confidence_interval_matrix(C2[,3:18],0.95)[1:16], col="blue")
lines(confidence_interval_matrix(C2[,3:18],0.95)[17:32], col="blue")

D1 <- data.matrix(f0_reports[f0_reports$tone=="D1",-c(1,c(22:26))])
plot(colMeans(D1)[3:18], type="l", xlim=c(1, 18), ylim=c(60, 250), xlab="Sampling points", ylab="F0 contour of tone D1")
lines(confidence_interval_matrix(D1[,3:18],0.95)[1:16], col="blue")
lines(confidence_interval_matrix(D1[,3:18],0.95)[17:32], col="blue")

D2 <- data.matrix(f0_reports[f0_reports$tone=="D2",-c(1,c(22:26))])
plot(colMeans(D2)[3:18], type="l", xlim=c(1, 18), ylim=c(60, 250), xlab="Sampling points", ylab="F0 contour of tone D2")
lines(confidence_interval_matrix(D2[,3:18],0.95)[1:16], col="blue")
lines(confidence_interval_matrix(D2[,3:18],0.95)[17:32], col="blue")

F0 contours on the same plot.

plot(colMeans(A1)[3:18], type="b", xlim=c(1, 18), ylim=c(60, 200), xlab="Sampling points", ylab="F0 (Hz)")
lines(colMeans(A2)[3:18],col="green", type="b", pch=19)
lines(colMeans(B1)[3:18],col="red",  type="b", pch=19)
lines(colMeans(B2)[3:18],col="purple", type="b",  pch=19)
lines(colMeans(C1)[3:18],col="blue",  type="b", pch=19)
lines(colMeans(C2)[3:18],col="orange",  type="b", pch=19)

# Add a legend
legend(1, 100, legend=c("A1", "A2", "B1", "B2", "C1", "C2"),
       col=c("black", "green", "red", "purple", "blue", "orange"), lty=1:2, cex=0.7)

Plot B1, B2, D1, D2 together.

plot(colMeans(B1)[3:18], type="b", col="blue", xlim=c(1, 18), ylim=c(60, 220), , xlab="Sampling points", ylab="F0 (Hz)")
lines(colMeans(B2)[3:18],col="purple", type="b",  pch=19)
lines(colMeans(D1)[3:18],col="pink",  type="b", pch=19)  ## D1 has a very strange contour.
lines(colMeans(D2)[3:18],col="black",  type="b", pch=19)

# Add a legend
legend(1, 100, legend=c("B1", "B2", "D1", "D2"),
       col=c("blue", "orange", "pink", "black"), lty=1:2, cex=0.7)

Estimate Regression Lines for Each Tone on Aggregate.

regression_report <- function(tone) {
  lm_tone <- lm(colMeans(tone)[3:18]~ c(1:16))
  plot(colMeans(tone)[3:18], pch = 16, cex = 1.3, xlim=c(1, 18), ylim=c(60, 250))
  abline(lm(colMeans(tone)[3:18] ~ c(1:16)))
  return(lm_tone)
}
## Call regression_report on all tones.
regression_report(A1)

## 
## Call:
## lm(formula = colMeans(tone)[3:18] ~ c(1:16))
## 
## Coefficients:
## (Intercept)      c(1:16)  
##    174.5199      -0.3935
regression_report(A2)

## 
## Call:
## lm(formula = colMeans(tone)[3:18] ~ c(1:16))
## 
## Coefficients:
## (Intercept)      c(1:16)  
##     153.905       -1.488
regression_report(B1)

## 
## Call:
## lm(formula = colMeans(tone)[3:18] ~ c(1:16))
## 
## Coefficients:
## (Intercept)      c(1:16)  
##     133.061        2.715
regression_report(B2)

## 
## Call:
## lm(formula = colMeans(tone)[3:18] ~ c(1:16))
## 
## Coefficients:
## (Intercept)      c(1:16)  
##     188.405       -5.683
regression_report(C1)

## 
## Call:
## lm(formula = colMeans(tone)[3:18] ~ c(1:16))
## 
## Coefficients:
## (Intercept)      c(1:16)  
##     161.437       -3.094
regression_report(C2)

## 
## Call:
## lm(formula = colMeans(tone)[3:18] ~ c(1:16))
## 
## Coefficients:
## (Intercept)      c(1:16)  
##     152.882        2.769
regression_report(D1)

## 
## Call:
## lm(formula = colMeans(tone)[3:18] ~ c(1:16))
## 
## Coefficients:
## (Intercept)      c(1:16)  
##     172.535        2.251
regression_report(D2)

## 
## Call:
## lm(formula = colMeans(tone)[3:18] ~ c(1:16))
## 
## Coefficients:
## (Intercept)      c(1:16)  
##     161.581       -1.977

Tone Contour Analysis on Different Noise Levels (Separately by Single vs. Tokens in Carriers)

# Plot F0 contours according to different levels

filter_f0 <- function(tone, noise, s) {
  if (s==TRUE) {
    tone_matrix <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise==noise & f0_reports$single=="1",-c(1,c(22:26))])
    return(tone_matrix)
  } else {
    tone_matrix <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise==noise & f0_reports$single=="0",-c(1,c(22:26))])
    return(tone_matrix)
  }
}

get_f0_range <- function(tone, s, condition) {
  if (s==TRUE) {
    tones <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise==condition & f0_reports$single=="1",-c(1,c(22:26))])
  max <- max(colMeans(tones)[3:18])
  min <- min(colMeans(tones)[3:18])
  range <- abs(max - min)
  return(range)
  } else {
    tones <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise==condition & f0_reports$single=="0",-c(1,c(22:26))])
  max <- max(colMeans(tones)[3:18])
  min <- min(colMeans(tones)[3:18])
  range <- abs(max - min)
  return(range)
  }
}
plot_f0_by_noise <- function(tone, s) {
  if (s==TRUE) {
    tone_quiet <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="0" & f0_reports$single=="1",-c(1,c(22:26))])
  tone_78 <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="78" & f0_reports$single=="1",-c(1,c(22:26))])
  tone_90 <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="90" & f0_reports$single=="1",-c(1,c(22:26))])
  plot(colMeans(tone_quiet)[3:18], type="l", xlim=c(1, 18), ylim=c(70, 250), xlab="Sampling points", ylab=paste("F0 for single tokens, tone", tone))
#  lines(confidence_interval_matrix(tone_quiet[,3:18],0.95)[1:16], col="black")
#  lines(confidence_interval_matrix(tone_quiet[,3:18],0.95)[16:32], col="black")
  lines(colMeans(tone_78)[3:18],col="blue")
#  lines(confidence_interval_matrix(tone_78[,3:18],0.95)[1:16], col="blue")
#  lines(confidence_interval_matrix(tone_78[,3:18],0.95)[16:32], col="blue")
  lines(colMeans(tone_90)[3:18],col="red")
#  lines(confidence_interval_matrix(tone_90[,3:18],0.95)[1:16], col="red")
#  lines(confidence_interval_matrix(tone_90[,3:18],0.95)[16:32], col="red")
  legend(1, 100, legend=c("quiet", "78dB", "90dB"),
       col=c("black", "blue", "red"), lty=1:2, cex=0.7)
  # Find regression coefficients and return them.
  c(summary(regression_report(tone_quiet))$coefficients[2,1], summary(regression_report(tone_78))$coefficients[2,1], summary(regression_report(tone_90))$coefficients[2,1])
  } else {
    tone_quiet <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="0" & f0_reports$single=="0",-c(1,c(22:26))])
  tone_78 <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="78" & f0_reports$single=="0",-c(1,c(22:26))])
  tone_90 <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="90" & f0_reports$single=="0",-c(1,c(22:26))])
  plot(colMeans(tone_quiet)[3:18], type="l", xlim=c(1, 18), ylim=c(70, 250), xlab="Sampling points", ylab=paste("F0 for tokens in carrier, tone", tone))
  lines(colMeans(tone_78)[3:18],col="blue")
  lines(colMeans(tone_90)[3:18],col="red")
    legend(1, 100, legend=c("quiet", "78dB", "90dB"),
       col=c("black", "blue", "red"), lty=1:2, cex=0.7)
  c(summary(regression_report(tone_quiet))$coefficients[2,1], summary(regression_report(tone_78))$coefficients[2,1], summary(regression_report(tone_90))$coefficients[2,1])
  }
}

coefficient_reports <- function(tone_matrix) {
  lm_model <- lm(colMeans(tone_matrix)[3:18] ~ c(1:16))
  summary(lm_model)$coefficients[2,1]
}

Get F0 range

for (x in c("A1", "A2", "B1", "B2", "C1", "C2", "D1", "D2")) {
  rangesingle <- c(get_f0_range(x, TRUE, 0), get_f0_range(x, TRUE, 78), get_f0_range(x, TRUE, 90))
rangecarrier <- c(get_f0_range(x, FALSE, 0), get_f0_range(x, FALSE, 78), get_f0_range(x, FALSE, 90))
print(rangesingle)
print(rangecarrier)
}
## [1]  6.446756 11.656587  5.009785
## [1] 6.811182 5.682943 8.916728
## [1] 19.34077 26.09196 23.68546
## [1] 16.42714 18.55408 22.16761
## [1] 40.30257 65.12644 82.23704
## [1] 29.35373 31.19463 31.75800
## [1]  39.16464 100.64520 102.42647
## [1]  62.81931  81.82895 103.03942
## [1] 27.13040 45.10562 45.15006
## [1] 42.47522 51.09777 64.17235
## [1] 90.26908 59.45983 51.34637
## [1] 41.20766 32.40360 26.13720
## [1] 43.38897 79.54610 61.42477
## [1] 61.17163 38.80816 52.86063
## [1] 20.77116 45.59789 23.65584
## [1] 35.97298 42.14857 28.86490

F0 and regression line for tone A1, single tokens.

plot_f0_by_noise("A1", TRUE)

## [1] -0.3186279 -0.8063768 -0.2594854

F0 and regression line for tone A2, single tokens.

plot_f0_by_noise("A2",TRUE)

## [1] -1.249683 -1.800296 -1.714919

F0 and regression line for tone B1, single tokens.

plot_f0_by_noise("B1", TRUE)

## [1] 2.309495 4.016975 5.183039

F0 and regression line for tone B2, single tokens.

plot_f0_by_noise("B2",TRUE)

## [1] -2.261342 -6.841648 -7.033730

F0 and regression line for tone C1, single tokens.

plot_f0_by_noise("C1",TRUE)

## [1] -1.441349 -2.268266 -2.558085

###F0 and regression line for tone C2, single tokens.

plot_f0_by_noise("C2", TRUE)

## [1] 3.599173 4.000898 4.149219

F0 and regression line for tone D1, single tokens.

plot_f0_by_noise("D1",TRUE)

## [1] 1.008148 4.267634 2.505821

F0 and regression line for tone D2, single tokens.

plot_f0_by_noise("D2", TRUE)

## [1] -1.386405 -3.235499 -1.578594

F0 and regression line for tone A1, tokens in carriers.

plot_f0_by_noise("A1", FALSE)

## [1] -0.4473569 -0.2207056 -0.3135566

F0 and regression line for tone A2, tokens in carriers.

plot_f0_by_noise("A2",FALSE)

## [1] -1.230934 -1.359417 -1.564121

F0 and regression line for tone B1, tokens in carriers.

plot_f0_by_noise("B1", FALSE)

## [1] 1.498756 1.660200 1.619737

F0 and regression line for tone B2, tokens in carriers.

plot_f0_by_noise("B2",FALSE)

## [1] -4.028040 -5.994461 -7.936588

F0 and regression line for tone C1, tokens in carriers.

plot_f0_by_noise("C1",FALSE)

## [1] -3.147131 -4.021417 -5.136960

F0 and regression line for tone C2, tokens in carriers.

plot_f0_by_noise("C2", FALSE)

## [1] 1.337868 1.872823 1.661997

F0 and regression line for tone D1, tokens in carriers.

plot_f0_by_noise("D1",FALSE)

## [1] 2.352847 1.723309 1.646091

F0 and regression line for tone D2, tokens in carriers.

plot_f0_by_noise("D2", FALSE)

## [1] -2.344592 -1.936387 -1.382912

All coefficients together in a table.

# Table of tone * noise (20x3)
tab <- matrix(,nrow=16, ncol=3, byrow=TRUE)
colnames(tab) <- c('quiet','noise 78','noise 90')
rownames(tab) <- c('A1 single','A2 single','B1 single', 'B2 single',
                   'C1 single','C2 single','D1 single', 'D2 single',
                   'A1 carrier','A2 carrier','B1 carrier', 'B2 carrier',
                   'C1 carrier','C2 carrier','D1 carrier', 'D2 carrier')
tab <- as.table(tab)
tab[1,1] = coefficient_reports(filter_f0("A1", "0", TRUE))
tab[1,2] = coefficient_reports(filter_f0("A1", "78", TRUE))
tab[1,3] = coefficient_reports(filter_f0("A1", "90", TRUE))

tab[2,1] = coefficient_reports(filter_f0("A2", "0", TRUE))
tab[2,2] = coefficient_reports(filter_f0("A2", "78", TRUE))
tab[2,3] = coefficient_reports(filter_f0("A2", "90", TRUE))

tab[3,1] = coefficient_reports(filter_f0("B1", "0", TRUE))
tab[3,2] = coefficient_reports(filter_f0("B1", "78", TRUE))
tab[3,3] = coefficient_reports(filter_f0("B1", "90", TRUE))

tab[4,1] = coefficient_reports(filter_f0("B2", "0", TRUE))
tab[4,2] = coefficient_reports(filter_f0("B2", "78", TRUE))
tab[4,3] = coefficient_reports(filter_f0("B2", "90", TRUE))

tab[5,1] = coefficient_reports(filter_f0("C1", "0", TRUE))
tab[5,2] = coefficient_reports(filter_f0("C1", "78", TRUE))
tab[5,3] = coefficient_reports(filter_f0("C1", "90", TRUE))

tab[6,1] = coefficient_reports(filter_f0("C2", "0", TRUE))
tab[6,2] = coefficient_reports(filter_f0("C2", "78", TRUE))
tab[6,3] = coefficient_reports(filter_f0("C2", "90", TRUE))

tab[7,1] = coefficient_reports(filter_f0("D1", "0", TRUE))
tab[7,2] = coefficient_reports(filter_f0("D1", "78", TRUE))
tab[7,3] = coefficient_reports(filter_f0("D1", "90", TRUE))

tab[8,1] = coefficient_reports(filter_f0("D2", "0", TRUE))
tab[8,2] = coefficient_reports(filter_f0("D2", "78", TRUE))
tab[8,3] = coefficient_reports(filter_f0("D2", "90", TRUE))

# carrier
tab[9,1] = coefficient_reports(filter_f0("A1", "0", FALSE))
tab[9,2] = coefficient_reports(filter_f0("A1", "78", FALSE))
tab[9,3] = coefficient_reports(filter_f0("A1", "90", FALSE))

tab[10,1] = coefficient_reports(filter_f0("A2", "0", FALSE))
tab[10,2] = coefficient_reports(filter_f0("A2", "78", FALSE))
tab[10,3] = coefficient_reports(filter_f0("A2", "90", FALSE))

tab[11,1] = coefficient_reports(filter_f0("B1", "0", FALSE))
tab[11,2] = coefficient_reports(filter_f0("B1", "78", FALSE))
tab[11,3] = coefficient_reports(filter_f0("B1", "90", FALSE))

tab[12,1] = coefficient_reports(filter_f0("B2", "0", FALSE))
tab[12,2] = coefficient_reports(filter_f0("B2", "78", FALSE))
tab[12,3] = coefficient_reports(filter_f0("B2", "90", FALSE))

tab[13,1] = coefficient_reports(filter_f0("C1", "0", FALSE))
tab[13,2] = coefficient_reports(filter_f0("C1", "78", FALSE))
tab[13,3] = coefficient_reports(filter_f0("C1", "90", FALSE))

tab[14,1] = coefficient_reports(filter_f0("C2", "0", FALSE))
tab[14,2] = coefficient_reports(filter_f0("C2", "78", FALSE))
tab[14,3] = coefficient_reports(filter_f0("C2", "90", FALSE))

tab[15,1] = coefficient_reports(filter_f0("D1", "0", FALSE))
tab[15,2] = coefficient_reports(filter_f0("D1", "78", FALSE))
tab[15,3] = coefficient_reports(filter_f0("D1", "90", FALSE))

tab[16,1] = coefficient_reports(filter_f0("D2", "0", FALSE))
tab[16,2] = coefficient_reports(filter_f0("D2", "78", FALSE))
tab[16,3] = coefficient_reports(filter_f0("D2", "90", FALSE))

write.table(tab)
## "quiet" "noise 78" "noise 90"
## "A1 single" -0.318627919315375 -0.806376813983049 -0.259485421041663
## "A2 single" -1.24968284844291 -1.80029563150916 -1.71491946960785
## "B1 single" 2.30949505477014 4.01697486877451 5.18303859324755
## "B2 single" -2.26134163315611 -6.84164757437782 -7.0337296884276
## "C1 single" -1.44134948069853 -2.26826647564951 -2.55808537042892
## "C2 single" 3.59917293631982 4.00089815257353 4.14921882723039
## "D1 single" 1.00814785333333 4.26763443833333 2.50582104857843
## "D2 single" -1.38640469803922 -3.23549863612745 -1.57859434083333
## "A1 carrier" -0.447356915526962 -0.220705641250616 -0.313556623161765
## "A2 carrier" -1.2309338377657 -1.35941741535539 -1.56412111213544
## "B1 carrier" 1.49875648317402 1.660199994375 1.61973741493872
## "B2 carrier" -4.02804043487556 -5.99446056809954 -7.93658801921946
## "C1 carrier" -3.14713130821078 -4.02141693886554 -5.13695962867647
## "C2 carrier" 1.33786824935049 1.87282284801471 1.66199699441176
## "D1 carrier" 2.35284662558823 1.7233087579902 1.64609118151961
## "D2 carrier" -2.34459238406863 -1.93638657588235 -1.38291206088235

Tone Contour Analysis on Different Noise Levels on Vowel A.

# Add vowel annotation.

f0_reports$vowel <- ifelse(grepl("a", f0_reports$syllable.name, ignore.case=T), "A",
ifelse(grepl("à", f0_reports$syllable.name, ignore.case=T), "A",
ifelse(grepl("á", f0_reports$syllable.name, ignore.case=T), "A",
ifelse(grepl("ả", f0_reports$syllable.name, ignore.case=T), "A",
ifelse(grepl("ã", f0_reports$syllable.name, ignore.case=T), "A",
ifelse(grepl("ạ", f0_reports$syllable.name, ignore.case=T), "A",
ifelse(grepl("ê", f0_reports$syllable.name, ignore.case=T), "E",
ifelse(grepl("ề", f0_reports$syllable.name, ignore.case=T), "E",
ifelse(grepl("ế", f0_reports$syllable.name, ignore.case=T), "E",
ifelse(grepl("ể", f0_reports$syllable.name, ignore.case=T), "E",
ifelse(grepl("ễ", f0_reports$syllable.name, ignore.case=T), "E",
ifelse(grepl("ệ", f0_reports$syllable.name, ignore.case=T), "E",
ifelse(grepl("u", f0_reports$syllable.name, ignore.case=T), "U",
ifelse(grepl("ù", f0_reports$syllable.name, ignore.case=T), "U",
ifelse(grepl("ú", f0_reports$syllable.name, ignore.case=T), "U",
ifelse(grepl("ủ", f0_reports$syllable.name, ignore.case=T), "U",
ifelse(grepl("ũ", f0_reports$syllable.name, ignore.case=T), "U",
ifelse(grepl("ụ", f0_reports$syllable.name, ignore.case=T), "U",
ifelse(grepl("ộ", f0_reports$syllable.name, ignore.case=T), "O","NA")))))))))))))))))))

# Convert vowel types to a factor variable
f0_reports$vowel <- as.factor(f0_reports$vowel)
head(f0_reports, 30)
# Plot F0 contour by vowels (not distinguishing single tokens or tokens in carriers.)

plot_f0_by_vowels <- function(tone, vowel) {
  if (vowel=="A") {
    tone_quiet <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="0" & f0_reports$vowel=="A",-c(1,c(22:26))])
  tone_78 <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="78" & f0_reports$vowel=="A",-c(1,c(22:26))])
  tone_90 <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="90" & f0_reports$vowel=="A",-c(1,c(22:26))])
  plot(colMeans(tone_quiet)[3:18], type="l", xlim=c(1, 18), ylim=c(70, 250), xlab="Sampling points", ylab=paste("F0 for vowel A, tone", tone))
  lines(colMeans(tone_78)[3:18],col="blue")
  lines(colMeans(tone_90)[3:18],col="red")
  # Find regression coefficients and return them.
  c(summary(regression_report(tone_quiet))$coefficients[2,1], summary(regression_report(tone_78))$coefficients[2,1], summary(regression_report(tone_90))$coefficients[2,1])
  } else if (vowel=="E") {
    tone_quiet <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="0" & f0_reports$vowel=="E",-c(1,c(22:26))])
  tone_78 <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="78" & f0_reports$vowel=="E",-c(1,c(22:26))])
  tone_90 <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="90" & f0_reports$vowel=="E",-c(1,c(22:26))])
  plot(colMeans(tone_quiet)[3:18], type="l", xlim=c(1, 18), ylim=c(70, 250), xlab="Sampling points", ylab=paste("F0 for vowel E, tone", tone))
  lines(colMeans(tone_78)[3:18],col="blue")
  lines(colMeans(tone_90)[3:18],col="red")
  # Find regression coefficients and return them.
  c(summary(regression_report(tone_quiet))$coefficients[2,1], summary(regression_report(tone_78))$coefficients[2,1], summary(regression_report(tone_90))$coefficients[2,1])
  } else {
  tone_quiet <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="0" & f0_reports$vowel=="U",-c(1,c(22:26))])
  tone_78 <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="78" & f0_reports$vowel=="U",-c(1,c(22:26))])
  tone_90 <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise=="90" & f0_reports$vowel=="U",-c(1,c(22:26))])
  plot(colMeans(tone_quiet)[3:18], type="l", xlim=c(1, 18), ylim=c(70, 250), xlab="Sampling points", ylab=paste("F0 for vowel U, tone", tone))
  lines(colMeans(tone_78)[3:18],col="blue")
  lines(colMeans(tone_90)[3:18],col="red")
  # Find regression coefficients and return them.
  c(summary(regression_report(tone_quiet))$coefficients[2,1], summary(regression_report(tone_78))$coefficients[2,1], summary(regression_report(tone_90))$coefficients[2,1])
  }
}

# Call functions

Tone A1 on A

plot_f0_by_vowels("A1", "A")

## [1] -0.14690974 -0.31942091 -0.04571527

Tone A1 on E

plot_f0_by_vowels("A1", "E")

## [1] -0.1059034 -0.7318152 -0.4137195

Tone A1 on U

plot_f0_by_vowels("A1", "U")

## [1] -0.8940176 -0.4878123 -0.4001283

Tone A2 on A

plot_f0_by_vowels("A2", "A")

## [1] -0.9017129 -1.4478054 -1.3585915

Tone A2 on E

plot_f0_by_vowels("A2", "E")

## [1] -1.185626 -1.632257 -1.589951

Tone A2 on U

plot_f0_by_vowels("A2", "U")

## [1] -1.628670 -1.662941 -1.967450

Tone B1 on A

plot_f0_by_vowels("B1", "A")

## [1] 2.119938 2.604628 3.487482

Tone B1 on E

plot_f0_by_vowels("B1", "E")

## [1] 2.708719 3.422099 3.781400

Tone B1 on U

plot_f0_by_vowels("B1", "U")

## [1] 0.8656728 2.4890358 2.9352821

Tone B2 on A

plot_f0_by_vowels("B2", "A")

## [1] -3.490682 -6.213033 -6.798165

Tone B2 on E

plot_f0_by_vowels("B2", "E")

## [1] -2.557656 -7.188424 -7.862296

Tone B2 on U

plot_f0_by_vowels("B2", "U")

## [1] -3.391056 -6.207349 -7.806966

Tone C1 on A

plot_f0_by_vowels("C1", "A")

## [1] -2.062575 -2.701781 -3.125616

Tone C1 on E

plot_f0_by_vowels("C1", "E")

## [1] -2.456957 -2.901117 -4.098411

Tone C1 on U

plot_f0_by_vowels("C1", "U")

## [1] -2.363189 -3.815132 -4.318540

Tone C2 on A

plot_f0_by_vowels("C2", "A")

## [1] 2.782585 3.233750 3.529397

Tone C2 on E

plot_f0_by_vowels("C2", "E")

## [1] 2.869950 2.970794 2.871590

Tone C2 on U

plot_f0_by_vowels("C2", "U")

## [1] 1.742820 2.606038 2.315837

Tone D1 on A

plot_f0_by_vowels("D1", "A")

## [1] 2.442698 2.203181 2.117786

Tone D1 on E

plot_f0_by_vowels("D1", "E")

## [1] 1.994048 4.776254 3.414007

Tone D1 on U

plot_f0_by_vowels("D1", "U")

## [1] 0.6047457 2.0069804 0.6960755

Tone D2 on A

plot_f0_by_vowels("D2", "A")

## [1] -1.348073 -3.284115 -1.984973

Tone D2 on E

plot_f0_by_vowels("D2", "E")

## [1] -0.9056471 -1.9051956 -0.7953201

Tone D2 on U

plot_f0_by_vowels("D2", "U")

## [1] -3.342776 -2.568517 -1.661967

Slope coefficients in a table

Plot F0 contours according to different levels

filter_f0 <- function(tone, vowel, noise) {
    tone_matrix <- data.matrix(f0_reports[f0_reports$tone==tone & f0_reports$noise==noise & f0_reports$vowel==vowel,-c(1,c(22:26))])
    return(tone_matrix)
}

# Table of tone * noise (24x3)
tab_vowel <- matrix(,nrow=24, ncol=3, byrow=TRUE)
colnames(tab_vowel) <- c('quiet','noise 78','noise 90')
rownames(tab_vowel) <- c('A1 A','A2 A','B1 A', 'B2 A',
                   'C1 A','C2 A','D1 A', 'D2 A',
                   'A1 E','A2 E','B1 E', 'B2 E',
                   'C1 E','C2 E','D1 E', 'D2 E',
                   'A1 U','A2 U','B1 U', 'B2 U',
                   'C1 U','C2 U','D1 U', 'D2 U')
tab_vowel <- as.table(tab_vowel)
tab_vowel[1,1] = coefficient_reports(filter_f0("A1", "A", "0"))
tab_vowel[1,2] = coefficient_reports(filter_f0("A1", "A", "78"))
tab_vowel[1,3] = coefficient_reports(filter_f0("A1", "A", "90"))

tab_vowel[2,1] = coefficient_reports(filter_f0("A2", "A", "0"))
tab_vowel[2,2] = coefficient_reports(filter_f0("A2", "A", "78"))
tab_vowel[2,3] = coefficient_reports(filter_f0("A2", "A", "90"))

tab_vowel[3,1] = coefficient_reports(filter_f0("B1", "A", "0"))
tab_vowel[3,2] = coefficient_reports(filter_f0("B1", "A", "78"))
tab_vowel[3,3] = coefficient_reports(filter_f0("B1", "A", "90"))

tab_vowel[4,1] = coefficient_reports(filter_f0("B2", "A", "0"))
tab_vowel[4,2] = coefficient_reports(filter_f0("B2", "A", "78"))
tab_vowel[4,3] = coefficient_reports(filter_f0("B2", "A", "90"))

tab_vowel[5,1] = coefficient_reports(filter_f0("C1", "A", "0"))
tab_vowel[5,2] = coefficient_reports(filter_f0("C1", "A", "78"))
tab_vowel[5,3] = coefficient_reports(filter_f0("C1", "A", "90"))

tab_vowel[6,1] = coefficient_reports(filter_f0("C2", "A", "0"))
tab_vowel[6,2] = coefficient_reports(filter_f0("C2", "A", "78"))
tab_vowel[6,3] = coefficient_reports(filter_f0("C2", "A", "90"))

tab_vowel[7,1] = coefficient_reports(filter_f0("D1", "A", "0"))
tab_vowel[7,2] = coefficient_reports(filter_f0("D1", "A", "78"))
tab_vowel[7,3] = coefficient_reports(filter_f0("D1", "A", "90"))

tab_vowel[8,1] = coefficient_reports(filter_f0("D2", "A", "0"))
tab_vowel[8,2] = coefficient_reports(filter_f0("D2", "A", "78"))
tab_vowel[8,3] = coefficient_reports(filter_f0("D2", "A", "90"))

tab_vowel[9,1] = coefficient_reports(filter_f0("A1", "E", "0"))
tab_vowel[9,2] = coefficient_reports(filter_f0("A1", "E", "78"))
tab_vowel[9,3] = coefficient_reports(filter_f0("A1", "E", "90"))

tab_vowel[10,1] = coefficient_reports(filter_f0("A2", "E", "0"))
tab_vowel[10,2] = coefficient_reports(filter_f0("A2", "E", "78"))
tab_vowel[10,3] = coefficient_reports(filter_f0("A2", "E", "90"))

tab_vowel[11,1] = coefficient_reports(filter_f0("B1", "E", "0"))
tab_vowel[11,2] = coefficient_reports(filter_f0("B1", "E", "78"))
tab_vowel[11,3] = coefficient_reports(filter_f0("B1", "E", "90"))

tab_vowel[12,1] = coefficient_reports(filter_f0("B2", "E", "0"))
tab_vowel[12,2] = coefficient_reports(filter_f0("B2", "E", "78"))
tab_vowel[12,3] = coefficient_reports(filter_f0("B2", "E", "90"))

tab_vowel[13,1] = coefficient_reports(filter_f0("C1", "E", "0"))
tab_vowel[13,2] = coefficient_reports(filter_f0("C1", "E", "78"))
tab_vowel[13,3] = coefficient_reports(filter_f0("C1", "E", "90"))

tab_vowel[14,1] = coefficient_reports(filter_f0("C2", "E", "0"))
tab_vowel[14,2] = coefficient_reports(filter_f0("C2", "E", "78"))
tab_vowel[14,3] = coefficient_reports(filter_f0("C2", "E", "90"))

tab_vowel[15,1] = coefficient_reports(filter_f0("D1", "E", "0"))
tab_vowel[15,2] = coefficient_reports(filter_f0("D1", "E", "78"))
tab_vowel[15,3] = coefficient_reports(filter_f0("D1", "E", "90"))

tab_vowel[16,1] = coefficient_reports(filter_f0("D2", "E", "0"))
tab_vowel[16,2] = coefficient_reports(filter_f0("D2", "E", "78"))
tab_vowel[16,3] = coefficient_reports(filter_f0("D2", "E", "90"))

tab_vowel[17,1] = coefficient_reports(filter_f0("A1", "U", "0"))
tab_vowel[17,2] = coefficient_reports(filter_f0("A1", "U", "78"))
tab_vowel[17,3] = coefficient_reports(filter_f0("A1", "U", "90"))

tab_vowel[18,1] = coefficient_reports(filter_f0("A2", "U", "0"))
tab_vowel[18,2] = coefficient_reports(filter_f0("A2", "U", "78"))
tab_vowel[18,3] = coefficient_reports(filter_f0("A2", "U", "90"))

tab_vowel[19,1] = coefficient_reports(filter_f0("B1", "U", "0"))
tab_vowel[19,2] = coefficient_reports(filter_f0("B1", "U", "78"))
tab_vowel[19,3] = coefficient_reports(filter_f0("B1", "U", "90"))

tab_vowel[20,1] = coefficient_reports(filter_f0("B2", "U", "0"))
tab_vowel[20,2] = coefficient_reports(filter_f0("B2", "U", "78"))
tab_vowel[20,3] = coefficient_reports(filter_f0("B2", "U", "90"))

tab_vowel[21,1] = coefficient_reports(filter_f0("C1", "U", "0"))
tab_vowel[21,2] = coefficient_reports(filter_f0("C1", "U", "78"))
tab_vowel[21,3] = coefficient_reports(filter_f0("C1", "U", "90"))

tab_vowel[22,1] = coefficient_reports(filter_f0("C2", "U", "0"))
tab_vowel[22,2] = coefficient_reports(filter_f0("C2", "U", "78"))
tab_vowel[22,3] = coefficient_reports(filter_f0("C2", "U", "90"))

tab_vowel[23,1] = coefficient_reports(filter_f0("D1", "U", "0"))
tab_vowel[23,2] = coefficient_reports(filter_f0("D1", "U", "78"))
tab_vowel[23,3] = coefficient_reports(filter_f0("D1", "U", "90"))

tab_vowel[24,1] = coefficient_reports(filter_f0("D2", "U", "0"))
tab_vowel[24,2] = coefficient_reports(filter_f0("D2", "U", "78"))
tab_vowel[24,3] = coefficient_reports(filter_f0("D2", "U", "90"))


write.table(tab_vowel)
## "quiet" "noise 78" "noise 90"
## "A1 A" -0.146909742181684 -0.319420906709556 -0.0457152684558818
## "A2 A" -0.90171286550633 -1.44780542455882 -1.35859145050261
## "B1 A" 2.11993762726103 2.60462774354779 3.48748175876838
## "B2 A" -3.4906822165625 -6.21303338441176 -6.79816521014705
## "C1 A" -2.06257541897059 -2.70178089919955 -3.12561635284926
## "C2 A" 2.78258485100521 3.23374956408088 3.52939672641544
## "D1 A" 2.44269826029412 2.20318070963235 2.11778581897059
## "D2 A" -1.34807296463235 -3.28411482419117 -1.98497264955882
## "A1 E" -0.105903441985294 -0.731815205100525 -0.413719474522057
## "A2 E" -1.18562585750186 -1.63225715200367 -1.58995051966912
## "B1 E" 2.708719054375 3.42209873454044 3.78140019012868
## "B2 E" -2.55765620919117 -7.18842448354779 -7.86229610726103
## "C1 E" -2.45695673621323 -2.9011167541728 -4.09841124216912
## "C2 E" 2.86994985193014 2.97079351851103 2.8715899378125
## "D1 E" 1.99404771727941 4.77625366588235 3.41400698977941
## "D2 E" -0.905647120955881 -1.90519561279412 -0.795320050441175
## "A1 U" -0.894017590882359 -0.487812328450225 -0.400128323327203
## "A2 U" -1.62867033176471 -1.66294086294835 -1.96744978167279
## "B1 U" 0.865672847691731 2.48903581663603 2.93528206338235
## "B2 U" -3.39105586987132 -6.20734888979779 -7.8069656917647
## "C1 U" -2.36318902818015 -3.81513201790441 -4.3185399036397
## "C2 U" 1.74281972450368 2.60603841829044 2.3158370682353
## "D1 U" 0.604745740808822 2.00698041897059 0.696075536397058
## "D2 U" -3.34277553757353 -2.56851738102941 -1.66196690257353